package acm.天梯赛练习2;

import java.util.PriorityQueue;
import java.util.Scanner;

public class F {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while (sc.hasNext()) {
            int[] arr=new int[sc.nextInt()];
            int k = sc.nextInt();
            for (int i = 0; i < arr.length; i++) {
                arr[i]=sc.nextInt();
            }
            PriorityQueue<Integer> queue=new PriorityQueue<>();
            for (int i = 0; i < arr.length; i++) {
                for (int j = i+1; j < arr.length; j++) {
                    if (queue.size()<k){
                        queue.add(arr[i]+arr[j]);
                    }else if (queue.peek()<arr[i]+arr[j]){
                        queue.poll();
                        queue.add(arr[i]+arr[j]);
                    }
                }
            }
            int [] res = new int[k];
            for (int i = k-1;i>=0;i--) {
                res[i]=queue.poll();
            }
            for (int r : res) {
                System.out.print(r+" ");
            }
            System.out.println();
        }
    }
}
